package com.example.Less.entity;

import com.example.Less.entity.PageRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class PhotoSearchQuery extends PageRequest {
    private String photoName;
    private String photoPath;
    private String type;
    private Integer projectId;
    private Integer isDeleted;

    // 添加排序字段映射（将数据库字段名转换为实体字段名）
    public String getOrderBy() {
        if (super.getOrderBy() == null) {
            return "createTime desc";
        }

        // 字段名映射
        String orderBy = super.getOrderBy();
        orderBy = orderBy.replace("create_time", "createTime");
        orderBy = orderBy.replace("photo_name", "photoName");
        orderBy = orderBy.replace("photo_path", "photoPath");
        orderBy = orderBy.replace("project_id", "projectId");
        orderBy = orderBy.replace("is_deleted", "isDeleted");

        return orderBy;
    }
}